package com.rocketmq.temp1.producer;

import com.rocketmq.temp1.dto.MemberDto;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ProducerController {
    private RocketMQTemplate rocketMQTemplate;
    @Autowired
    public ProducerController(RocketMQTemplate rocketMQTemplate) {
        this.rocketMQTemplate = rocketMQTemplate;
    }
    @GetMapping(value = "/sendMember")
    public String sendMember() {
        MemberDto memberDto = new MemberDto(System.currentTimeMillis(), "周孝兵" + System.currentTimeMillis());
        rocketMQTemplate.convertAndSend("sm-platform-topic", memberDto);
        return "success";
    }
}
